unit uNewContractCreateAction;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ComCtrls, DB, OracleData;

type
  TfmNewContractCreateAction = class(TForm)
    odsNewContractCreateAction: TOracleDataSet;
    Label1: TLabel;
    Label2: TLabel;
    dtpActionDate: TDateTimePicker;
    cbActiontype: TComboBox;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    ActionTypeId : integer;
    ActionDate : string;
    ActionName : string;

    function Execute : boolean;
  end;

var
  fmNewContractCreateAction: TfmNewContractCreateAction;

implementation

uses uMain;

{$R *.dfm}

function TfmNewContractCreateAction.Execute: boolean;
begin
  result := false;
  if ShowModal = mrOk then
  begin
    ActionTypeId := integer(cbActiontype.Items.Objects[cbActiontype.ItemIndex]);
    ActionDate := FormatDateTime('dd.mm.yyyy', dtpActionDate.Date);
    ActionName :=  cbActiontype.Items[cbActiontype.ItemIndex];

    result := true;
  end;
end;

procedure TfmNewContractCreateAction.FormShow(Sender: TObject);
begin
  cbActiontype.Items.Clear;

  odsNewContractCreateAction.Close;
  odsNewContractCreateAction.SQL.Text := 'select catp_id as id, name from contract_action_types';
  odsNewContractCreateAction.Open;

  odsNewContractCreateAction.First;

  while not (odsNewContractCreateAction.eof) do
  begin
    cbActiontype.Items.AddObject(odsNewContractCreateAction.FieldByName('NAME').AsString, TObject(odsNewContractCreateAction.FieldByName('ID').AsInteger));

    odsNewContractCreateAction.Next;
  end;
end;

end.
